<?php

namespace app\common\order\model;

use think\Model;
use think\model\concern\SoftDelete;

class PrebookOrder extends Model
{
    use SoftDelete;
    protected $defaultSoftDelete = 0;

    protected $type = [
        'use_date' => 'timestamp',
    ];

    public function getUseDateAttr($value): string
    {
        // 格式化时间 2025-06-01 根据时间戳给出上午还是下午
        $time = date('H', $value);
        if ($time < 12) {
            $time = '上午';
        } else {
            $time = '下午';
        }

        $date = date('Y-m-d', $value);
        return $date . ' ' . $time;
    }
}